package org.jix.framework.common.validator;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @author stark
 * @date 2025/5/12 14:59
 * @description
 **/
public class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> {
    @Override
    public void initialize(PhoneNumber constraintAnnotation) {
        //初始化
    }

    @Override
    public boolean isValid(String phoneNumber, ConstraintValidatorContext context) {
        //校验逻辑，正则表达式判断是否为十一位数字
        return phoneNumber != null && phoneNumber.matches("\\d{11}");
    }
}
